//package net.jarang.android.support;
//
//import java.io.File;
//import java.io.IOException;
//import java.io.InputStream;
//import java.util.Map;
//import java.util.Map.Entry;
//
//import net.jarang.android.saleoffline.SaleContext;
//import net.jarang.support.StreamUtils;
//
//import org.apache.http.HttpEntity;
//import org.apache.http.HttpResponse;
//import org.apache.http.HttpVersion;
//import org.apache.http.client.ClientProtocolException;
//import org.apache.http.client.HttpClient;
//import org.apache.http.client.methods.HttpGet;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.entity.mime.MultipartEntity;
//import org.apache.http.entity.mime.content.ContentBody;
//import org.apache.http.entity.mime.content.FileBody;
//import org.apache.http.impl.client.DefaultHttpClient;
//import org.apache.http.params.BasicHttpParams;
//import org.apache.http.params.CoreProtocolPNames;
//import org.apache.http.params.HttpConnectionParams;
//import org.apache.http.params.HttpParams;
//import org.apache.http.util.EntityUtils;
//
//import android.util.Log;
//
//public class RestClient {
//	public static String post(String url, Map<String, File> uploadFiles, Map<String, Object> params) throws Exception  {
//		HttpClient httpclient = new DefaultHttpClient();
//		httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
//
//		Log.v(SaleContext.SALEOFFLINE, url);
//		
//		HttpPost httpPost = new HttpPost(url);
//		MultipartEntity mpEntity = new MultipartEntity();
//		if (uploadFiles != null) {
//			for (Entry<String, File> entry : uploadFiles.entrySet()) {
//				ContentBody cbFile = new FileBody(entry.getValue(), "image/jpeg");
//				mpEntity.addPart(entry.getKey(), cbFile);
//			}
//		}
//		httpPost.setEntity(mpEntity);
//		
//		HttpParams httpParams = new BasicHttpParams();
//		if (params != null) {
//			for (Entry<String, Object>  entry : params.entrySet()) {
//				httpParams.setParameter(entry.getKey(), entry.getValue());
//			}
//		}
//		httpPost.setParams(httpParams);
//		
//		Log.v(SaleContext.SALEOFFLINE, httpPost.getRequestLine().toString());
//		HttpResponse response = httpclient.execute(httpPost);
//		HttpEntity resEntity = response.getEntity();
//
//		Log.v(SaleContext.SALEOFFLINE, response.getStatusLine().toString());
//		if (resEntity != null) {
//		  Log.v(SaleContext.SALEOFFLINE, EntityUtils.toString(resEntity).toString());
//		}
//		if (resEntity != null) {
//		  resEntity.consumeContent();
//		}
//
//		httpclient.getConnectionManager().shutdown();
//
//		return null;
//	}
//
//	public static String get(String url) throws ClientProtocolException, IOException {
//		HttpClient httpclient = new DefaultHttpClient();
//		HttpParams params = httpclient.getParams();
//		HttpConnectionParams.setConnectionTimeout(params, 3000);
//		HttpConnectionParams.setSoTimeout(params, 3000);
//		HttpGet httpget = new HttpGet(url);
//		HttpResponse response;
//		String result = null;
//		
////		try {
//			response = httpclient.execute(httpget);
//			Log.i("Praeda", response.getStatusLine().toString());
//			HttpEntity entity = response.getEntity();
//			
//			if (entity != null) {
//				InputStream instream = entity.getContent();
//				result = StreamUtils.streamToString(instream, "UTF-8");
//				Log.i("Praeda", result);
//				instream.close();
//			}
////		} catch (ClientProtocolException e) {
////			// TODO Auto-generated catch block
////			e.printStackTrace();
////		} catch (IOException e) {
////			// TODO Auto-generated catch block
////			e.printStackTrace();
////		}
//		return result;
//	}
//}
